<?php
declare (strict_types = 1);

namespace app\controller;

use app\facade\Param;
use app\helpers\api\ApiResponse;
use app\model\News;
use app\model\Signup;
use app\model\User;
use app\model\Vegetables;
use think\facade\Db;
use think\Request;

class NewsController
{
    use ApiResponse;
    /**
     * 新闻列表
     * @return \think\Response
     */
    public function index(Request $request)
    {
        $query = News::field('id,title,type');
        $query = Param::newsParam($request->param(), $query);
        return $this->success($query->paginate($request->param('page_size', 15)));
    }

    //新闻详情
    public function show(News $news){
        return $this->success($news);
    }

    //添加新闻
   public function store(Request $request)
   {
       News::create($request->param());
       return $this->created();
   }



}
